package com.aos.iot.socket.common.client;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ClientBoxFactor {

    private final Map<String, IClientBox> clientBoxMap;

    public ClientBoxFactor(List<IClientBox> clientBoxes) {
        this.clientBoxMap = clientBoxes.stream().collect(Collectors.toMap(IClientBox::protocolName, IClientBox::client));
    }

    public <C extends IClientBox> C getClientBox(String protocolName) {
        return (C) clientBoxMap.get(protocolName);
    }

}
